package spotGUI.utils;

import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;

import managers.messengerManager.MessengerManager;
import utils.UserState;


public class UserStateListCellRenderer implements ListCellRenderer {

	private DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
	
	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		
		UserState state = (UserState) value;
		
		JLabel listCellRendererComponent = (JLabel)defaultRenderer.getListCellRendererComponent(
				list, value, index, isSelected, cellHasFocus);
		listCellRendererComponent.setBackground(UIManager.getColor("Button.background"));
		listCellRendererComponent.setIcon(new ImageIcon(MessengerManager.getSharedInstance().getFeedbackManager().getIconPath(state)));
		listCellRendererComponent.setText((state.getText()));

		return listCellRendererComponent;
	}
}
